﻿using AspDotNet.Core7.First.Services;

namespace AspDotNet.Core7.First.Middlewares
{
    public partial class ContentMiddleware
    {
        private TotalUsers Users { get; set; }
        private RequestDelegate NextMiddleware { get; set; }
        public ContentMiddleware(RequestDelegate nextMiddleware)
        {
            NextMiddleware = nextMiddleware;
        }

        public async Task Invoke(HttpContext httpContext)
        {
            if (httpContext.Request.Path.ToString() == "/middleware")
            {
                await httpContext.Response.WriteAsync("This is from the content middleware, Total Users: " + Users.TUsers());
            }
            else
            {
                await NextMiddleware.Invoke(httpContext);
            }
        }
    }
}
